package com.isoft.mapper;

import com.isoft.entity.DfmeFpttEntity;
import org.apache.ibatis.annotations.*;

@Mapper
public interface DfmeFpttMapper {

    @Insert("INSERT INTO MSG_META(SENDER, RECEIVER, SEQUENCE_NUMBER, DATE_TIME, MSG_TYPE, SUB_TYPE) " +
            "VALUES(" +
            "#{meta.sender,jdbcType=VARCHAR}, " +
            "#{meta.receiver,jdbcType=VARCHAR}, " +
            "#{meta.sequenceNumber,jdbcType=NUMERIC}, " +
            "TO_TIMESTAMP(#{meta.dateTime,jdbcType=VARCHAR}, 'yyyymmddhh24miss'), " +
            "#{meta.type,jdbcType=VARCHAR}, " +
            "#{meta.subType,jdbcType=VARCHAR})")
    void insertMeta(DfmeFpttEntity entity);

    @Insert("INSERT INTO FLIGHT_BASE(" +
            "FLIGHT_ID, FLIGHT_FILE_ID, FLIGHT_IDENTIFIER) " +
            "VALUES(" +
            "#{dflt.flightId,jdbcType=NUMERIC}, " +
            "#{dflt.flightFileId,jdbcType=VARCHAR}, " +
            "#{dflt.flightIdentifier,jdbcType=VARCHAR})")
    int insertFlightBase(DfmeFpttEntity entity);

    @Insert("INSERT INTO FLIGHT_ROUTE(" +
            "FLIGHT_ID, AIRPORT_CODE, AIRPORT_SEQ, SCHEDULED_TIME) " +
            "VALUES(" +
            "#{dflt.flightId,jdbcType=NUMERIC}, " +
            "#{dflt.airportCode,jdbcType=VARCHAR}, " +
            "#{dflt.airportSeq,jdbcType=NUMERIC}, " +
            "TO_TIMESTAMP(#{dflt.plannedTime,jdbcType=VARCHAR}, 'yyyymmddhh24miss'))")
    int insertFlightRoute(DfmeFpttEntity entity);
}